| word = getHello() |
| #main.py |
| #functions.py |
| def getHello(): |
| print(word) |
| c = "hello" |
| return c |
| word = getHello() |
| #main.py |
| #functions.py |
| def getHello(): |
| print(word) |
|     c = "hello" |
|     return c |
| 1 | #functions.py |
| 2 | def getHello(): |
| 3 |     c = "hello" |
| 4 |     return c |
| 5 | |
| 6 | #main.py |
| 7 | word = getHello() |
| 8 | print(word) |
| return a |
| #main.py |
| def addTwo(a): |
| n = addTwo(n) |
| #functions.py |
| n = 2 |
| print(n) |
| a = a + 2 |
|     return a |
| #main.py |
| def addTwo(a): |
| n = addTwo(n) |
| #functions.py |
| n = 2 |
| print(n) |
|     a = a + 2 |
| 1 | #functions.py |
| 2 | def addTwo(a): |
| 3 |     a = a + 2 |
| 4 |     return a |
| 5 | |
| 6 | #main.py |
| 7 | n = 2 |
| 8 | n = addTwo(n) |
| 9 | print(n) |
| #main.py |
| s = "You okay" |
| s = question(s) |
| return a |
| def question(a): |
| print(s) |
| a = a + "?" |
| #functions.py |
| #main.py |
| s = "You okay" |
| s = question(s) |
|     return a |
| def question(a): |
| print(s) |
|     a = a + "?" |
| #functions.py |
| 1 | #functions.py |
| 2 | def question(a): |
| 3 |     a = a + "?" |
| 4 |     return a |
| 5 | |
| 6 | #main.py |
| 7 | s = "You okay" |
| 8 | s = question(s) |
| 9 | print(s) |
| a = a + a |
| s = "word" |
| return a |
| #main.py |
| print(b) |
| def twoWord(a): |
| #functions.py |
| b = twoWord(s) |
|     a = a + a |
| s = "word" |
|     return a |
| #main.py |
| print(b) |
| def twoWord(a): |
| #functions.py |
| b = twoWord(s) |
| 1 | #functions.py |
| 2 | def twoWord(a): |
| 3 |     a = a + a |
| 4 |     return a |
| 5 | |
| 6 | #main.py |
| 7 | s = "word" |
| 8 | b = twoWord(s) |
| 9 | print(b) |
| b = twoWord(b) |
| a = a + a |
| #functions.py |
| #main.py |
| return a |
| b = twoWord(b) |
| print(b) |
| s = "word" |
| def twoWord(a): |
| b = twoWord(b) |
|     a = a + a |
| #functions.py |
| #main.py |
|     return a |
| b = twoWord(b) |
| print(b) |
| s = "word" |
| def twoWord(a): |
| 1 | #functions.py |
| 2 | def twoWord(a): |
| 3 |     a = a + a |
| 4 |     return a |
| 5 | |
| 6 | #main.py |
| 7 | s = "word" |
| 8 | b = twoWord(b) |
| 9 | b = twoWord(b) |
| 10 | print(b) |
| #functions.py |
| return False |
| return True |
| print(e) |
| n = 10 |
| else: |
| e = isEven(n) |
| def isEven(a): |
| #main.py |
| if a % 2 == 0: |
| #functions.py |
|         return False |
|         return True |
| print(e) |
| n = 10 |
|     else: |
| e = isEven(n) |
| def isEven(a): |
| #main.py |
|     if a % 2 == 0: |
| 1 | #functions.py |
| 2 | def isEven(a): |
| 3 |     if a % 2 == 0: |
| 4 |         return True |
| 5 |     else: |
| 6 |         return False |
| 7 | |
| 8 | #main.py |
| 9 | n = 10 |
| 10 | e = isEven(n) |
| 11 | print(e) |
| if string[x] == letter: |
| return count |
| count += 1 |
| #functions.py |
| n = howMany("hello","e") |
| print(n) |
| count = 0 |
| n = howMany("hello","l") |
| for x in range(len(string)): |
| #main.py |
| def howMany(string,letter): |
| print(n) |
|         if string[x] == letter: |
|     return count |
|             count += 1 |
| #functions.py |
| n = howMany("hello","e") |
| print(n) |
|     count = 0 |
| n = howMany("hello","l") |
|     for x in range(len(string)): |
| #main.py |
| def howMany(string,letter): |
| print(n) |
| 1 | #functions.py |
| 2 | def howMany(string,letter): |
| 3 |     count = 0 |
| 4 |     for x in range(len(string)): |
| 5 |         if string[x] == letter: |
| 6 |             count += 1 |
| 7 |     return count |
| 8 | |
| 9 | #main.py |
| 10 | n = howMany("hello","e") |
| 11 | print(n) |
| 12 | n = howMany("hello","l") |
| 13 | print(n) |
| for x in range(len(arr)): |
| item = arr[len(arr) - 1 - x] |
| newArr.append(item) |
| #functions.py |
| print(newArr) |
| return newArr |
| newArr = reverseArray([1,2,3,4]) |
| newArr = [] |
| #main.py |
| def reverseArray(arr): |
|     for x in range(len(arr)): |
|         item = arr[len(arr) - 1 - x] |
|         newArr.append(item) |
| #functions.py |
| print(newArr) |
|     return newArr |
| newArr = reverseArray([1,2,3,4]) |
|     newArr = [] |
| #main.py |
| def reverseArray(arr): |
| 1 | #functions.py |
| 2 | def reverseArray(arr): |
| 3 |     newArr = [] |
| 4 |     for x in range(len(arr)): |
| 5 |         item = arr[len(arr) - 1 - x] |
| 6 |         newArr.append(item) |
| 7 |     return newArr |
| 8 | |
| 9 | #main.py |
| 10 | newArr = reverseArray([1,2,3,4]) |
| 11 | print(newArr) |
| for x in range(len(arr)): |
| count = 0 |
| count = count + arr[x] |
| #main.py |
| print(r) |
| r = sumArray([2,3,2,3,2]) |
| return count |
| #functions.py |
| def sumArray(arr): |
|     for x in range(len(arr)): |
|     count = 0 |
|         count = count + arr[x] |
| #main.py |
| print(r) |
| r = sumArray([2,3,2,3,2]) |
|     return count |
| #functions.py |
| def sumArray(arr): |
| 1 | #functions.py |
| 2 | def sumArray(arr): |
| 3 |     count = 0 |
| 4 |     for x in range(len(arr)): |
| 5 |         count = count + arr[x] |
| 6 |     return count |
| 7 | |
| 8 | #main.py |
| 9 | r = sumArray([2,3,2,3,2]) |
| 10 | print(r) |
| es = es + " " |
| es = es + s[x] |
| #functions.py |
| es = "" |
| else: |
| for x in range(len(s)): |
| if s[x] == " ": |
| return es |
| r = moreSpaces("This is a test") |
| print(r) |
| #main.py |
| def moreSpaces(s): |
|             es = es + " " |
|             es = es + s[x] |
| #functions.py |
|     es = "" |
|         else: |
|     for x in range(len(s)): |
|         if s[x] == " ": |
|     return es |
| r = moreSpaces("This is a test") |
| print(r) |
| #main.py |
| def moreSpaces(s): |
| 1 | #functions.py |
| 2 | def moreSpaces(s): |
| 3 |     es = "" |
| 4 |     for x in range(len(s)): |
| 5 |         if s[x] == " ": |
| 6 |             es = es + " " |
| 7 |         else: |
| 8 |             es = es + s[x] |
| 9 |     return es |
| 10 | |
| 11 | #main.py |
| 12 | r = moreSpaces("This is a test") |
| 13 | print(r) |
| es = es + " " |
| print(r) |
| def moreSpaces(s): |
| es = "" |
| for x in range(len(s)): |
| #functions.py |
| else: |
| r = moreSpaces("This is a test") |
| #main.py |
| if s[x] == " ": |
| r = moreSpaces(r) |
| return es |
| es = es + s[x] |
|             es = es + " " |
| print(r) |
| def moreSpaces(s): |
|     es = "" |
|     for x in range(len(s)): |
| #functions.py |
|         else: |
| r = moreSpaces("This is a test") |
| #main.py |
|         if s[x] == " ": |
| r = moreSpaces(r) |
|     return es |
|             es = es + s[x] |
| 1 | #functions.py |
| 2 | def moreSpaces(s): |
| 3 |     es = "" |
| 4 |     for x in range(len(s)): |
| 5 |         if s[x] == " ": |
| 6 |             es = es + " " |
| 7 |         else: |
| 8 |             es = es + s[x] |
| 9 |     return es |
| 10 | |
| 11 | #main.py |
| 12 | r = moreSpaces("This is a test") |
| 13 | r = moreSpaces(r) |
| 14 | print(r) |
| #main.py |
| r = moreSpaces(moreSpaces("This is a test")) |
| print(r) |
| 1 | #main.py |
| 2 | r = moreSpaces(moreSpaces("This is a test")) |
| 3 | print(r) |
| #Remember when return is executed nothing else runs, if it reaches here it has only seen 1s or 0s |
| print(r) |
| for x in range(len(s)): |
| return True |
| #main.py |
| r = isBinary("122101") |
| if s[x] != "0" and s[x] != "1": |
| print(r) |
| r = isBinary("10101") |
| def isBinary(s): |
| return False |
| #functions.py |
|     #Remember when return is executed nothing else runs, if it reaches here it has only seen 1s or 0s |
| print(r) |
|     for x in range(len(s)): |
|     return True |
| #main.py |
| r = isBinary("122101") |
|         if s[x] != "0" and s[x] != "1": |
| print(r) |
| r = isBinary("10101") |
| def isBinary(s): |
|             return False |
| #functions.py |
| 1 | #functions.py |
| 2 | def isBinary(s): |
| 3 |     for x in range(len(s)): |
| 4 |         if s[x] != "0" and s[x] != "1": |
| 5 |             return False |
| 6 |     #Remember when return is executed nothing else runs, if it reaches here it has only seen 1s or 0s |
| 7 |     return True |
| 8 | |
| 9 | #main.py |
| 10 | r = isBinary("10101") |
| 11 | print(r) |
| 12 | |
| 13 | r = isBinary("122101") |
| 14 | print(r) |
| #main.py |
| print(zeroes) |
| zeroes = howManyZeroes(200300) |
| return count |
| break |
| count = count + 1 |
| def howManyZeroes(num): |
| print(zeroes) |
| if char == "0": |
| #functions.py |
| count = 0 |
| else: |
| num = str(num) |
| char = num[len(num)-1-x] |
| zeroes = howManyZeroes(230000) |
| for x in range(len(num)): |
| #main.py |
| print(zeroes) |
| zeroes = howManyZeroes(200300) |
|     return count |
|             break |
|             count = count + 1 |
| def howManyZeroes(num): |
| print(zeroes) |
|         if char == "0": |
| #functions.py |
|     count = 0 |
|         else: |
|     num = str(num) |
|         char = num[len(num)-1-x] |
| zeroes = howManyZeroes(230000) |
|     for x in range(len(num)): |
| 1 | #functions.py |
| 2 | def howManyZeroes(num): |
| 3 |     num = str(num) |
| 4 |     count = 0 |
| 5 |     for x in range(len(num)): |
| 6 |         char = num[len(num)-1-x] |
| 7 |         if char == "0": |
| 8 |             count = count + 1 |
| 9 |         else: |
| 10 |             break |
| 11 |     return count |
| 12 | |
| 13 | #main.py |
| 14 | zeroes = howManyZeroes(200300) |
| 15 | print(zeroes) |
| 16 | zeroes = howManyZeroes(230000) |
| 17 | print(zeroes) |
| return commas + " and " + arr[-1] |
| #functions.py |
| print(z) |
| commas = ", ".join(arr[:-1]) |
| return arr[0] |
| if len(arr) == 0: |
| def printMultiplePeople(arr): |
| #main.py |
| arr = ["Bob","Fred"] |
| else: |
| return "" |
| elif len(arr) == 1: |
| z = printMultiplePeople(arr) |
|         return commas + " and " + arr[-1] |
| #functions.py |
| print(z) |
|         commas = ", ".join(arr[:-1]) |
|         return arr[0] |
|     if len(arr) == 0: |
| def printMultiplePeople(arr): |
| #main.py |
| arr = ["Bob","Fred"] |
|     else: |
|         return "" |
|     elif len(arr) == 1: |
| z = printMultiplePeople(arr) |
| 1 | #functions.py |
| 2 | def printMultiplePeople(arr): |
| 3 |     if len(arr) == 0: |
| 4 |         return "" |
| 5 |     elif len(arr) == 1: |
| 6 |         return arr[0] |
| 7 |     else: |
| 8 |         commas = ", ".join(arr[:-1]) |
| 9 |         return commas + " and " + arr[-1] |
| 10 | |
| 11 | #main.py |
| 12 | arr = ["Bob","Fred"] |
| 13 | z = printMultiplePeople(arr) |
| 14 | print(z) |
| for x in range(len(results)): |
| if num.isdigit() == False: |
| print("Pass") |
| if isfloat(results[x]) == answers[x]: |
| def isfloat(num): |
| if num[0] == "-": |
| elif num.count(".") > 1: |
| results = ["1","2.4","-2.4","a","a.5","-3","4.0","ab.cd","1000","2.4.1"] |
| else: |
| print("Fail") |
| #main.py |
| return False |
| return True |
| #functions.py |
| num = num.replace(".","") |
| num = num[1:] |
| num = str(num) |
| if num.count(".") == 1: |
| return False |
| answers = [True,True,True,False,False,True,True,False,True,False] |
| for x in range(len(results)): |
|     if num.isdigit() == False: |
|     print("Pass") |
|   if isfloat(results[x]) == answers[x]: |
| def isfloat(num): |
|     if num[0] == "-": |
|     elif num.count(".") > 1: |
| results = ["1","2.4","-2.4","a","a.5","-3","4.0","ab.cd","1000","2.4.1"] |
|   else: |
|     print("Fail") |
| #main.py |
|         return False |
|     return True |
| #functions.py |
|         num = num.replace(".","") |
|         num = num[1:] |
|     num = str(num) |
|     if num.count(".") == 1: |
|         return False |
| answers = [True,True,True,False,False,True,True,False,True,False] |
| 1 | #functions.py |
| 2 | def isfloat(num): |
| 3 |     num = str(num) |
| 4 |      |
| 5 |     if num.count(".") == 1: |
| 6 |         num = num.replace(".","") |
| 7 |     elif num.count(".") > 1: |
| 8 |         return False |
| 9 |      |
| 10 |     if num[0] == "-": |
| 11 |         num = num[1:] |
| 12 |      |
| 13 |     if num.isdigit() == False: |
| 14 |         return False |
| 15 |      |
| 16 |     return True |
| 17 | |
| 18 | #main.py |
| 19 | results = ["1","2.4","-2.4","a","a.5","-3","4.0","ab.cd","1000","2.4.1"] |
| 20 | answers = [True,True,True,False,False,True,True,False,True,False] |
| 21 | |
| 22 | for x in range(len(results)): |
| 23 |   if isfloat(results[x]) == answers[x]: |
| 24 |     print("Pass") |
| 25 |   else: |
| 26 |     print("Fail") |
| s = s + arr[x][y] |
| s = s + "\n" |
| for y in range(len(arr[x])): |
| s = "" |
| #main.py |
| for x in range(len(arr)): |
| return s |
| example = [[".",".","."],["-","-","-"],["@","@","@"]] |
| string = print2DArray(example) |
| def print2DArray(arr): |
| print(string) |
| #functions.py |
|             s = s + arr[x][y] |
|         s = s + "\n" |
|         for y in range(len(arr[x])): |
|     s = "" |
| #main.py |
|     for x in range(len(arr)): |
|     return s |
| example = [[".",".","."],["-","-","-"],["@","@","@"]] |
| string = print2DArray(example) |
| def print2DArray(arr): |
| print(string) |
| #functions.py |
| 1 | #functions.py |
| 2 | def print2DArray(arr): |
| 3 |     s = "" |
| 4 |     for x in range(len(arr)): |
| 5 |         for y in range(len(arr[x])): |
| 6 |             s = s + arr[x][y] |
| 7 |         s = s + "\n" |
| 8 |     return s |
| 9 | |
| 10 | #main.py |
| 11 | example = [[".",".","."],["-","-","-"],["@","@","@"]] |
| 12 | string = print2DArray(example) |
| 13 | print(string) |
| newarr.append(arr[x][n]) |
| #main.py |
| newarr = [] |
| example = [["1","2","3"],["4","5","6"],["7","8","9"]] |
| for x in range(len(arr)): |
| #functions.py |
| def getColumn(arr,n): |
| newArray = getColumn(example,1) |
| print(newArray) |
| return newarr |
|         newarr.append(arr[x][n]) |
| #main.py |
|     newarr = [] |
| example = [["1","2","3"],["4","5","6"],["7","8","9"]] |
|     for x in range(len(arr)): |
| #functions.py |
| def getColumn(arr,n): |
| newArray = getColumn(example,1) |
| print(newArray) |
|     return newarr |
| 1 | #functions.py |
| 2 | def getColumn(arr,n): |
| 3 |     newarr = [] |
| 4 |     for x in range(len(arr)): |
| 5 |         newarr.append(arr[x][n]) |
| 6 |     return newarr |
| 7 | |
| 8 | #main.py |
| 9 | example = [["1","2","3"],["4","5","6"],["7","8","9"]] |
| 10 | newArray = getColumn(example,1) |
| 11 | print(newArray) |
| #Add an extra char to the end so the final item is added |
| sa = splitArr("this is a test string"," ") |
| newarr.append(es) |
| print(sa) |
| #functions.py |
| es = es + string[x] |
| def splitArr(string,char): |
| string = string + char |
| es = "" |
| newarr = [] |
| if string[x] == char: |
| es = "" |
| return newarr |
| for x in range(len(string)): |
| #main.py |
| else: |
|     #Add an extra char to the end so the final item is added |
| sa = splitArr("this is a test string"," ") |
|             newarr.append(es) |
| print(sa) |
| #functions.py |
|             es = es + string[x] |
| def splitArr(string,char): |
|     string = string + char |
|     es = "" |
|     newarr = [] |
|         if string[x] == char: |
|             es = "" |
|     return newarr |
|     for x in range(len(string)): |
| #main.py |
|         else: |
| 1 | #functions.py |
| 2 | def splitArr(string,char): |
| 3 |     #Add an extra char to the end so the final item is added |
| 4 |     string = string + char |
| 5 |     newarr = [] |
| 6 |     es = "" |
| 7 |     for x in range(len(string)): |
| 8 |         if string[x] == char: |
| 9 |             newarr.append(es) |
| 10 |             es = "" |
| 11 |         else: |
| 12 |             es = es + string[x] |
| 13 |     return newarr |
| 14 | |
| 15 | #main.py |
| 16 | sa = splitArr("this is a test string"," ") |
| 17 | print(sa) |